//
//  UITableView+Extension.swift
//  XingCeHelper
//
//  Created by 申铭 on 2023/2/8.
//

import UIKit
import EmptyPage

extension UITableView {
    
    /// 定义空白View
    ///
    /// - Parameters:
    ///   - imageName: 图片名称
    ///   - text: 提示信息
    ///   - btnTitle: 按钮名称
    ///   - tapEvent: 点击事件
    func emptyView(imageName: String, text: String, btnTitle: String = "nil", tapEvent: (() -> Void)? = nil) {
        let emptyView = EmptyPageView.Template.standard
        .config(imageView: { imageView in
            imageView.set(image: UIImage(named: imageName)?.withRenderingMode(.alwaysOriginal))
        })
        .config(titleLabel: { textLabel in
            textLabel.font = UIFont.systemFont(ofSize: 14)
            textLabel.textColor = .systemGray
            textLabel.set(text: text)
        })
        .config(button: { button in
            button.setTitle(btnTitle, for: .normal)
            button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
            button.set(tapEvent: tapEvent)
        })
        .layout(view: .button, types: [.width(150)])
        .layout(view: .imageView, types: [.afterSpac(0)])
        .layout(view: .titleLabel, types: [.afterSpac(30)])
        .mix().layout(vertical: .topSpacer(20))
        
        self.ep.set(emptyView: emptyView)
    }
}
